<?

function smarty_function_draggable( $params, $smarty ) {

	// make sure we have dependent plugins
	require_once $smarty->_get_plugin_filepath( 'modifier', 'escape' );

	$id = $params['id'] ? $params['id'] : Smutty_Utils::getUniqueId();
	$text = $params['text'];
	$image = $params['image'] ? Smutty_Utils::getBaseUrl() . $params['image'] : '';
	$class = $params['class'];

	// create the link!
	if ( $text )
		echo '<div id="' . $id . '" class="' . $class . '">' . smarty_modifier_escape($text) . '</div>';
	elseif ( $image )
		echo '<img id="' . $id . '" class="' . $class . '" src="' . $image . '" alt="" />';
	else
		new Smutty_Exception( 'you need to specify either some text or an image from drag_source', 'SmartyFunction_draggable' );

	echo '<script type="text/javascript">new Draggable(\'' . $id . '\',{revert:true});</script>';

}

?>